package com.suxin.aop;

import com.suxin.annotation.CurrentUser;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;

import java.util.Optional;

/**
 * @author Tang
 * @classname AspectTest
 * @description [  ]
 * @date 2021/5/8 21:21
 */
//@Component
//@Aspect
public class AspectTest {

    // @within(com.suxin.annotation.CurrentUser) 切入类
    // @annotation(com.suxin.annotation.CurrentUser) 切入方法
    //

//    @Pointcut(value = "@within(com.suxin.annotation.CurrentUser) || @annotation(com.suxin.annotation.CurrentUser)")
    @Pointcut(value = "execution(* com.suxin.service.*.*(..))")
    public void pointCut2() {
    }

    @Before(value = "pointCut2()")
    public void before2(JoinPoint joinPoint) {
        System.out.println("Before method....");
    }

    @Before(value = "pointCut2()")
    public void after2() {
        System.out.println("After method....");
    }
}